package com.example.demo.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import com.example.demo.entity.Food;



@Repository
public interface Food_Mapper extends Basic_Mapper<Food> {
	
	
	@Select("select food.*,foodtype.name foodtype_name from food inner join foodtype"
			+ " on food.foodtype_id=foodtype.id  ${where} ${limit}")
	public List<Food> select(@Param("where")String where,@Param("limit") String limit);
	
	@Delete("delete from Food where id=#{id}")
	public void delete(int id);
	
	@Insert("insert into Food(name,foodtype_id,picurl,price,status) values(#{name},#{foodtype_id},#{picurl},#{price},#{status})")
	public void insert(Food t);
	
	@Update("update Food set name=#{name},foodtype_id=#{foodtype_id},picurl=#{picurl},price=#{price},status=#{status} where id=#{id}")
	public void update(Food t);
	
	@Select("select * from Food where id=#{id}")
	public Food getById(int id);
}
